package com.example.demo.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


@Configuration
public class WebMvcConfiguration implements WebMvcConfigurer {

    @Value("${file.server-path}")
    public String serverPath;

    @Value("${file.local-path}")
    public String localPath;

    /**
     * springboot中SpringMVC让开发者去配置文件上传的额外静态资源服务配置
     * @author chenlirun
     * @date 2021/11/20 15:34
     */
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler(serverPath).addResourceLocations("file:"+localPath);
    }
}
